<template>
    <div class="ma-content-block lg:flex justify-between p-4">
      <!-- CRUD 组件 -->
      <ma-crud :options="options" :columns="columns" ref="crudRef">
        <template #tableBeforeButtons>
            <a-button type="primary" @click="handleAdd(1,{})">新增</a-button>
        </template>
        <template #money="{ record }">
            <div>{{(record?.money - 0) < 0?record?.money.toFixed(2) + '(已欠费)':record?.money.toFixed(2)}}</div>
        </template>
        <template #tag="{ record }">
          <div class="flex justify_center" >
            <div class="" v-for="(item,index) in record.tag" style="margin-right: 10px">
              <a-tag :color="item.tag_color"> {{ item.tag_name }}</a-tag>
            </div>
          </div>
        </template>
        
        <template #name="{ record }">
          <a-tooltip :content="record?.name">
            <div class="ellipsis">{{record?.name}}</div>
          </a-tooltip>
          
        </template>
        <template #operationBeforeExtend="{ record }">
          <!-- <a-link @click="openShow(record,'')">账单明细</a-link> -->
          <a-link @click="handleUserList(record)">账号管理</a-link>
          <a-link @click="addMoneyRef.open({type:2,dept_id:record.id}, () => {
                        load()
                    })">充值</a-link>
          <!-- <a-link @click="withdrawRef.open({type:2,dept_id:record.id,money:record.money}, () => {
                        load()
                    })">提现</a-link> -->
          <a-link @click="withdrawRef.open({type:2,dept_id:record.id,money:record.money}, () => {
                        load()
                    })">退款</a-link>
          <a-link @click="handleDrtail(record)">详情</a-link>
          <a-link @click="handleAdd(2,record)">编辑</a-link>
        </template>
      </ma-crud>
      <a-drawer
        :footer="false"
        :width="1440"
        v-model:visible="userVisible"
        >
        <template #title> 用户管理 </template>
        <financeLedgerUser v-if="userVisible" :dept_id="dept_id" />
      </a-drawer>

      <!-- 详情弹窗 -->
      <a-modal :mask-closable="false"  v-model:visible="visible_detail" :width="1080" @cancel="handleDetailCancel" :footer="false">
        <template #title>
          客户详情
        </template>
        <div v-if="visible_detail">
          <div class="flex justify_between align_center marbot12">
            <div class="flex align_center">
              <div class="font18 bold marr12 hei">{{setailItem.name}}</div>
              <div class="font14" :class="setailItem.status == 1?'green':'hui'">· {{setailItem.status == 1?'正常':'停用'}}</div>
            </div>
            <div class="flex align_center" >
              <div class="font14 hei" style="margin-right: 16px">创建时间：{{setailItem.created_at}}</div>
              <a-button type="primary" @click="addMoneyRef.open({type:2,dept_id:setailItem.id}, () => {
                        load()
                    })">充值</a-button>
            </div>
          </div>
          <div class="huiBox flex justify_between marbot12">
            <div class="flex_1 flex flex_column justify_center">
              <div class="font14 text_center marbot4">余额</div>
              <div class="bule  bold text_center flex align_end justify_center">
                <div class="font20 bold marr2 ">{{setailItem.money}} </div>
                <div class="font14 "> 元</div>
                <div v-if="(setailItem.money - 0) < 0" style="color:red">（已欠费）</div>
              </div>
            </div>
            <div class="flex_1 flex flex_column justify_center">
              <div class="font14 text_center marbot4">累计到运车数</div>
              <div class="bule  bold text_center flex align_end justify_center">
                <div class="font20 bold marr2 " >-</div>
                <div class="font14 "> 车</div>
              </div>
            </div>
            <div class="flex_1 flex flex_column justify_center">
              <div class="font14 text_center marbot4">累计发运车数</div>
              <div class="bule  bold text_center flex align_end justify_center">
                <div class="font20 bold marr2 ">-</div>
                <div class="font14 "> 车</div>
              </div>
            </div>
            <div class="flex_1 flex flex_column justify_center">
              <div class="font14 text_center marbot4">应收款金额</div>
              <div class="bule  bold text_center flex align_end justify_center">
                <div class="font20 bold marr2 ">{{setailItem.pay_money}} </div>
                <div class="font14 "> 元</div>
              </div>
            </div>
            <div class="flex_1 flex flex_column justify_center">
              <div class="font14 text_center marbot4">应付款金额</div>
              <div class="bule  bold text_center flex align_end justify_center">
                <div class="font20 bold marr2 ">{{setailItem.wait_pay_money}} </div>
                <div class="font14 "> 元</div>
              </div>
            </div>
            
          </div>
          <div class="tabBox flex marbot12">
            <div class="tab cursor" :class="detailCentent == 0?'activeTab':''" @click="handleTab(0)">基础信息</div>
            <div class="tab cursor" :class="detailCentent == 1?'activeTab':''" @click="handleTab(1)">结算日期</div>
          </div>
          <div class="contenBox" style="overflow: auto;">
              <!-- 基础信息 -->
              <div class=""  v-if="detailCentent == 0">
                <div style="margin-bottom: 16px">
                  <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
                    <template #title>
                      <div style="color:rgba(0, 82, 217, 1);font-weight:600">基本信息</div>
                    </template>
                    <div class="flex marbot24 align_center" style="width:100%">
                      <div class="flex" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">客户名称：</div>
                        <div>{{setailItem.name || '-'}}</div>
                      </div>
                      <div  class="flex" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                        <div  class="font14 marbot4">客户类型：</div>
                        <div>{{ setailItem.customer_type == 1?'企业':'个人' }}</div>
                      </div>
                      <div class="flex" style="width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">经办人：</div>
                        <div>{{setailItem.leader || '-'}}</div>
                        <!-- <a-input v-model="setailItem.leader" placeholder="请输入负责人" allow-clear  /> -->
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%">
                      <div class="flex" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">联系电话：</div>
                        <div>{{setailItem.phone || '-'}}</div>
                        <!-- <a-input v-model="setailItem.phone" placeholder="请输入负责人" allow-clear  /> -->
                      </div>
                      <div class="flex" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">邮箱：</div>
                        <div>{{setailItem.e_mail || '-'}}</div>
                        <!-- <a-input v-model="setailItem.phone" placeholder="请输入邮箱" allow-clear  /> -->
                      </div>
                      <div class="flex" style="width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">纳税人识别号：</div>
                        <div>{{setailItem.card_id || '-'}}</div>
                        <!-- <a-input v-model="setailItem.card_id" placeholder="请输入纳税人识别号" allow-clear  /> -->
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%">
                      <div style="margin-right:36px;width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">标签组:</div>
                        <a-select v-model="setailItem.tag_ids"  placeholder="请选择标签" multiple disabled >
                          <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                        </a-select>
                      </div>
                      <div style="margin-right:36px;width:calc((100% - 72px) / 3);">
                        <div class="font14 marbot4">状态</div>
                        <div class="flex align_center" style="height:32px">
                          <a-space size="large">
                            <a-radio-group v-model="setailItem.status" :options="statusList" disabled />
                          </a-space>
                        </div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%">
                      <div style="width:100%;">
                        <div class="font14 marbot4">营业执照：</div>
                        <ma-upload v-model="setailItem.file" type='image' />
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%">
                      <div style="width:100%;">
                        <div class="font14 marbot4">备注:</div>
                        <a-textarea placeholder="请输入备注" v-model="setailItem.remark" allow-clear disabled />
                      </div>
                    </div>
                  </a-card>
                </div>
                <div style="margin-bottom: 16px">
                  <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
                    <template #title>
                      <div style="color:rgba(0, 82, 217, 1);font-weight:600">工商信息</div>
                    </template>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">公司名称：</div>
                        <div>{{setailItem.company_data.companyName || '-'}}</div>
                        <!-- <a-input v-model="setailItem.company_data.companyName" placeholder="请输入公司名称" allow-clear  /> -->
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">公司类型：</div>
                        <div>{{setailItem.company_data.companyType || '-'}}</div>
                        <!-- <a-input v-model="setailItem.company_data.companyType" placeholder="请输入公司类型" allow-clear  /> -->
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">法定代表人：</div>
                        <div>{{setailItem.company_data.legalPerson || '-'}}</div>
                        <!-- <a-input v-model="setailItem.company_data.legalPerson" placeholder="请输入法定代表人" allow-clear  /> -->
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">法人类型：</div>
                        <div>{{setailItem.company_data.legalPersonType || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">电话号码：</div>
                        <div>{{setailItem.company_data.phoneNumber || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">电话备注：</div>
                        <div>{{setailItem.company_data.phoneNumber_note || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">注册资本：</div>
                        <div>{{setailItem.company_data.capital || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">实收注册资金：</div>
                        <div>{{setailItem.company_data.realCapital || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">注册码：</div>
                        <div>{{setailItem.company_data.companyCode || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">企业信用代码：</div>
                        <div>{{setailItem.company_data.creditNo || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">组织机构代码：</div>
                        <div>{{setailItem.company_data.orgCode || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">经营范围：</div>
                        <div>{{setailItem.company_data.businessScope || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">登记机关：</div>
                        <div>{{setailItem.company_data.authority || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">经营状态：</div>
                        <div>{{setailItem.company_data.companyStatus || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">成立时间：</div>
                        <div>{{setailItem.company_data.establishDate || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">营业开始时间：</div>
                        <div>{{setailItem.company_data.operationStartdate || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">营业结束时间：</div>
                        <div>{{setailItem.company_data.operationEnddate || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">核准日期：</div>
                        <div>{{setailItem.company_data.issueDate || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">省份：</div>
                        <div>{{setailItem.company_data.province || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">省份行政区号：</div>
                        <div>{{setailItem.company_data.provinceCode || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">地市：</div>
                        <div>{{setailItem.company_data.city || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">地市行政区号：</div>
                        <div>{{setailItem.company_data.cityCode || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">地区：</div>
                        <div>{{setailItem.company_data.district || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">地区行政区号：</div>
                        <div>{{setailItem.company_data.districtCode || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">注册地址：</div>
                        <div>{{setailItem.company_data.companyAddress || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">行业：</div>
                        <div>{{setailItem.company_data.industry || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">曾用名：</div>
                        <div>{{setailItem.company_data.historyNames || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">更新时间：</div>
                        <div>{{setailItem.company_data.lastUpdatedTime || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">登记状态：</div>
                        <div>{{setailItem.company_data.companyStatus || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">邮箱：</div>
                        <div>{{setailItem.company_data.email || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">邮箱备注：</div>
                        <div>{{setailItem.company_data.email_note || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">地址：</div>
                        <div>{{setailItem.company_data.address || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        <div class="font14 marbot4" style="width: 100px;">地址备注：</div>
                        <div>{{setailItem.company_data.address_note || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 1">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">网址：</div>
                        <div>{{setailItem.company_data.website || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;margin-right:36px;" >
                        <div class="font14 marbot4" style="width: 100px;">网址备注：</div>
                        <div>{{setailItem.company_data.website_note || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;" >
                        
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%" v-if="setailItem.customer_type == 2">
                      <div class="flex align_center" style="flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">抬头名称：</div>
                        <div>{{setailItem.company_data.companyName || '-'}}</div>
                      </div>
                    </div>
                  </a-card>
                </div>
                <div style="margin-bottom: 16px">
                  <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
                    <template #title>
                      <div style="color:rgba(0, 82, 217, 1);font-weight:600">银行账户信息</div>
                    </template>
                    <div class="flex marbot24" style="width:100%">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">开户银行：</div>
                        <div>{{setailItem.opening_bank || '-'}}</div>
                      </div>
                      <div class="flex align_center" style="flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">银行账号：</div>
                        <div>{{setailItem.account || '-'}}</div>
                      </div>
                    </div>
                    <div class="flex marbot24" style="width:100%">
                      <div class="flex align_center" style="margin-right:36px;flex:1;">
                        <div class="font14 marbot4" style="width: 100px;">账户名称：</div>
                        <div>{{setailItem.account_name || '-'}}</div>
                      </div>
                      <div style="flex:1;">
                        
                      </div>
                    </div>
                  </a-card>


                </div>
                <!-- <a-button type="primary" @click="update">保存</a-button> -->
              </div>
              <!-- 结算日期 -->
              <div v-if="detailCentent == 1">
                <div class="mt-5">
                  周期结算账单日:
                  <a-input-number style="width: 4em;"  :min="1" :max="31"  v-model="haseinfo.money.bill_day"/>
                  号
                </div>
                <div class="mt-2 bule">
                  每月X号生成周期账单。例如，账单日设置的1日，则每月1号生成上月业务产生的账单。
                </div>

                <div class="mt-5">
                  周期账单结算日:
                  <a-input-number style="width: 4em;"  :min="1" :max="31" v-model="haseinfo.money.settle_day"/>
                  号
                </div>
                <div class="mt-2 bule">
                  每月X号结算上一个月的周期账单，若是客户超期未结算周期账单，则禁止提货。例如，结算日设置的5号，则每月5号之前完成账单结算，若是未完成结算将不能继续提货。
                </div>
                <a-button type="primary" @click="deptMoneyUpdate" class="mt-5">保存</a-button>
              </div>
              
          </div>
        </div>
      </a-modal>


      <!-- 新增/编辑 -->
      <a-modal :mask-closable="false"  v-model:visible="visible_Add" :width="1080" @cancel="visible_Add=false" :on-before-ok="handleAddOk">
        <template #title>
          {{addType == 1?'新增':'编辑'}}
        </template>
        <div class="contenBox" style="overflow: auto;">
          <div style="margin-bottom: 16px">
            <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
              <template #title>
                <div style="color:rgba(0, 82, 217, 1);font-weight:600">基本信息</div>
              </template>
              <div class="flex marbot24 align_center" style="width:100%" >
                <div class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 ">类型：</div>
                  <div class="flex align_center" style="height:32px">
                    <a-space size="large">
                      <a-radio-group v-model="addItem.type" :options="typeList" @change="handleType" />
                    </a-space>
                  </div>
                </div>
                <div  class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div  class="font14 ">客户类型：</div>
                  <div class="flex align_center" style="height:32px">
                    <a-space size="large">
                      <a-radio-group v-model="addItem.customer_type" :options="customerTypeList" />
                    </a-space>
                  </div>
                </div>
                <div class="flex align_center" style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 ">状态：</div>
                  <div class="flex align_center" style="height:32px">
                    <a-space size="large">
                      <a-radio-group v-model="addItem.status" :options="statusList" />
                    </a-space>
                  </div>
                </div>
              </div>
              <div class="flex marbot24 align_center" style="width:100%" v-if="addItem.customer_type == 1">
                <div  style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4 flex align_center"><div style="color: red;">*</div>客户名称：</div>
                  <a-select style="flex:1" :loading="loading" placeholder="请选择客户名称" v-model="addItem.name"
                            @search="handleSearch" :filter-option="false" @change='handleYinhanInfo($event)'  allow-search >
                    <a-option v-for="item of deptSearchList" :value="item.creditNo" >{{item.companyName}}</a-option>
                  </a-select>
                  <!-- <a-input v-model="addItem.name" placeholder="请输入客户名称" allow-clear @change="handleKehuInfo" /> -->
                </div>
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <!-- <div class="font14 marbot4">负责人:</div> -->
                  <div class="font14 marbot4 flex align_center">经办人：</div>
                  <a-input v-model="addItem.leader" placeholder="请输入经办人" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4 flex align_center"><div style="color: red;">*</div>联系电话:</div>
                  <a-input v-model="addItem.phone" placeholder="请输入联系电话" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">邮箱:</div>
                  <a-input v-model="addItem.e_mail" placeholder="请输入邮箱" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">纳税人识别号:</div>
                  <a-input v-model="addItem.card_id" placeholder="请输入纳税人识别号" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">标签组:</div>
                  <a-select v-model="addItem.tag_ids"  placeholder="请选择标签" multiple>
                    <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                  </a-select>
                </div>
              </div>
              <div class="flex marbot24 align_center" style="width:100%" v-if="addItem.customer_type == 2">
                <div  style="margin-right:36px;width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">客户名称：</div>
                  <a-input v-model="addItem.name" placeholder="请输入客户名称" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">联系电话:</div>
                  <a-input v-model="addItem.phone" placeholder="请输入联系电话" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">邮箱:</div>
                  <a-input v-model="addItem.e_mail" placeholder="请输入邮箱" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 2">
                <div style="width:calc((100% - 72px) / 3);margin-right:36px;">
                  <div class="font14 marbot4">身份证号:</div>
                  <a-input v-model="addItem.card_id" placeholder="请输入身份证号" allow-clear  />
                </div>
                <div style="width:calc((100% - 72px) / 3);">
                  <div class="font14 marbot4">标签组:</div>
                  <a-select v-model="addItem.tag_ids"  placeholder="请选择标签" multiple>
                    <a-option v-for="item of tagList" :value="item.id" :label="item.name" />
                  </a-select>
                </div>
              </div>
              <div class="flex marbot24" style="width:100%">
                <div style="width:100%;">
                  <div class="font14 marbot4">营业执照：</div>
                  <ma-upload v-model="addItem.file" type='image' />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%">
                <div style="width:100%;">
                  <div class="font14 marbot4">备注:</div>
                  <a-textarea placeholder="请输入备注" v-model="addItem.remark" allow-clear/>
                </div>
              </div>
            </a-card>
          </div>
          <div style="margin-bottom: 16px">
            <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
              <template #title>
                <div style="color:rgba(0, 82, 217, 1);font-weight:600">工商信息</div>
              </template>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">公司名称：</div>
                  <a-input v-model="addItem.company_data.companyName" placeholder="请输入公司名称" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">公司类型：</div>
                  <a-input v-model="addItem.company_data.companyType" placeholder="请输入公司类型" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">法定代表人：</div>
                  <a-input v-model="addItem.company_data.legalPerson" placeholder="请输入法定代表人" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">法人类型：</div>
                  <a-input v-model="addItem.company_data.legalPersonType" placeholder="请输入法人类型" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">电话号码：</div>
                  <a-input v-model="addItem.company_data.phoneNumber" placeholder="请输入电话号码" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">电话备注：</div>
                  <a-input v-model="addItem.company_data.phoneNumber_note" placeholder="请输入电话备注" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">注册资本：</div>
                  <a-input v-model="addItem.company_data.capital" placeholder="请输入注册资本" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">实收注册资金：</div>
                  <a-input v-model="addItem.company_data.realCapital" placeholder="请输入实收注册资金" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">注册码：</div>
                  <a-input v-model="addItem.company_data.companyCode" placeholder="请输入注册码" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">企业信用代码：</div>
                  <a-input v-model="addItem.company_data.creditNo" placeholder="请输入企业信用代码" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">组织机构代码：</div>
                  <a-input v-model="addItem.company_data.orgCode" placeholder="请输入组织机构代码" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">经营范围：</div>
                  <a-input v-model="addItem.company_data.businessScope" placeholder="请输入经营范围" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">登记机关：</div>
                  <a-input v-model="addItem.company_data.authority" placeholder="请输入登记机关" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">经营状态：</div>
                  <a-input v-model="addItem.company_data.companyStatus" placeholder="请输入经营状态" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">成立时间：</div>
                  <a-input v-model="addItem.company_data.establishDate" placeholder="请输入成立时间" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">营业开始时间：</div>
                  <a-input v-model="addItem.company_data.operationStartdate" placeholder="请输入营业开始时间" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">营业结束时间：</div>
                  <a-input v-model="addItem.company_data.operationEnddate" placeholder="请输入营业结束时间" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">核准日期：</div>
                  <a-input v-model="addItem.company_data.issueDate" placeholder="请输入核准日期" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">省份：</div>
                  <a-input v-model="addItem.company_data.province" placeholder="请输入省份" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">省份行政区号：</div>
                  <a-input v-model="addItem.company_data.provinceCode" placeholder="请输入省份行政区号" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">地市：</div>
                  <a-input v-model="addItem.company_data.city" placeholder="请输入地市" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">地市行政区号：</div>
                  <a-input v-model="addItem.company_data.cityCode" placeholder="请输入地市行政区号" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">地区：</div>
                  <a-input v-model="addItem.company_data.district" placeholder="请输入地区" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">地区行政区号：</div>
                  <a-input v-model="addItem.company_data.districtCode" placeholder="请输入地区行政区号" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">注册地址：</div>
                  <a-input v-model="addItem.company_data.companyAddress" placeholder="请输入注册地址" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">行业：</div>
                  <a-input v-model="addItem.company_data.industry" placeholder="请输入行业" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">曾用名：</div>
                  <a-input v-model="addItem.company_data.historyNames" placeholder="请输入曾用名" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">更新时间：</div>
                  <a-input v-model="addItem.company_data.lastUpdatedTime" placeholder="请输入更新时间" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">登记状态：</div>
                  <a-input v-model="addItem.company_data.companyStatus" placeholder="请输入登记状态" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">邮箱：</div>
                  <a-input v-model="addItem.company_data.email" placeholder="请输入邮箱" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">邮箱备注：</div>
                  <a-input v-model="addItem.company_data.email_note" placeholder="请输入邮箱备注" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">地址：</div>
                  <a-input v-model="addItem.company_data.address" placeholder="请输入地址" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  <div class="font14 marbot4" style="width: 100px;">地址备注：</div>
                  <a-input v-model="addItem.company_data.address_note" placeholder="请输入地址备注" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 1">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">网址：</div>
                  <a-input v-model="addItem.company_data.website" placeholder="请输入网址" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;margin-right:36px;" >
                  <div class="font14 marbot4" style="width: 100px;">网址备注：</div>
                  <a-input v-model="addItem.company_data.website_note" placeholder="请输入网址备注" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;" >
                  
                </div>
              </div>
              <div class="flex marbot24" style="width:100%" v-if="addItem.customer_type == 2">
                <div class="flex align_center" style="flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">抬头名称：</div>
                  <a-input v-model="addItem.companyName" placeholder="请输入抬头名称" allow-clear  />
                </div>
              </div>
            </a-card>
          </div>
          <div >
            <a-card  :header-style="{background:'#f5f5f5',color:'rgba(0, 82, 217, 1)',fontWeight:'600'}">
              <template #title>
                <div style="color:rgba(0, 82, 217, 1);font-weight:600">银行账户信息</div>
              </template>
              <div class="flex marbot24" style="width:100%">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">开户银行：</div>
                  <a-input v-model="addItem.opening_bank" placeholder="请输入开户银行" allow-clear  />
                </div>
                <div class="flex align_center" style="flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">银行账号：</div>
                  <a-input v-model="addItem.account" placeholder="请输入银行账号" allow-clear  />
                </div>
              </div>
              <div class="flex marbot24" style="width:100%">
                <div class="flex align_center" style="margin-right:36px;flex:1;">
                  <div class="font14 marbot4" style="width: 100px;">账户名称：</div>
                  <a-input v-model="addItem.account_name" placeholder="请输入账户名称" allow-clear  />
                </div>
                <div style="flex:1;">
                  
                </div>
              </div>
            </a-card>
          </div>
        </div>
      </a-modal>

      <!-- 充值 -->
      <AddMoneyModal
        ref="addMoneyRef"
      />

      <!-- 提现 -->
      <withdraw
        ref="withdrawRef"
      />
    </div>
  </template>
  <script setup>
  import {ref, reactive, nextTick, onMounted} from 'vue'
  import financialPeriodic from '@/api/financial/financialPeriodic'
  import FinancialTopDeptMoney from "@/api/financial/financialTopDeptMoney";
  import financialMoneyLog from '@/api/financial/financialMoneyLog'
  import financialPayOrder from '@/api/financial/financialPayOrder'
  import user from "@/api/system/user";
  import dept from "@/api/system/dept";
  import { Message,Modal } from '@arco-design/web-vue'
  import { pinyin } from "pinyin-pro"
  import tool from '@/utils/tool'
  import { request } from "@/utils/request.js";
  import * as common from '@/utils/common'
  import {cloneDeep} from "lodash";
  import PayOrderList from "@/views/financial/financeLedger/ledgerindex.vue"
  import financeLedgerUser from "@/views/financial/financeLedger/financeLedgerUser.vue"
  import MaFormModal from "@/components/ma-form-modal/index.vue";
  import AddMoneyModal from "@/views/financial/moneyLog/AddMoney.vue"
  import withdraw from "@/views/financial/financeLedger/withdraw.vue"
  import { color } from 'echarts';
  const addMoneyRef = ref()
//   import PayOrderList from "@/views/financial/payOrder/index.vue"
  const crudRef = ref()
  const withdrawRef = ref()
  const loading = ref(false)
  const deptSearchList = ref([])
  const visible_Add = ref(false)
  const addType = ref()
  const visible = ref()
  const payOrderRef = ref()
  const is_one = ref(true)
  const dept_id = ref('')
  const userVisible = ref(false)
  const haseinfo = ref({
    money:{
      settle_day:0,
      bill_day:0,
    }
  })
  const filterOption = (v,option)=>{
    return option.keywords.some(keywords=>keywords.includes(v))
  }
  const checkColumns = [
    {
      title: "备注",
      dataIndex: "remark",
      formType: "textarea"
    }
  ]
  const addItem = ref({
    type:1,
    customer_type:1,
    status:1,
    name:'',
    leader:'',
    phone:'',
    e_mail:'',
    card_id:'',
    file:'',
    tag_ids:[],
    remark:'',
    // 工商信息
    company_data:{
      companyName:'',  // 公司名称
      companyType:'',  // 公司类型
      legalPerson:'',  // 法定代表人
      legalPersonType:'',  //  法人类型
      phoneNumber:'',   // 电话号码
      phoneNumber_note:'',   // 电话备注
      capital:'',       // 注册资本
      realCapital:'',   // 实收注册资金
      companyCode:'',  // 注册码
      creditNo:'',  // 企业信用代码
      orgCode:'',   // 组织机构代码
      businessScope:'',  // 经营范围
      authority:'',  // 登记机关
      companyStatus:'',   // 经营状态
      establishDate:'',  // 成立时间
      operationStartdate:'',  // 营业期限开始时间
      operationEnddate:'',  // 营业期限结束时间
      issueDate:'',  // 核准日期
      province:'',  // 省份
      provinceCode:'',   // 省份行政区号
      city:'',   // 地市
      cityCode:'',  // 地市行政区号
      district:'', // 地区
      districtCode:'',  // 地区行政区号
      companyAddress:'',  // 注册地址
      industry:'',  // 行业
      historyNames:'', // 曾用名
      lastUpdatedTime:'',  // 更新时间
      companyStatus:'',  // 登记状态
      email:'',   // 邮箱
      email_note:'',  // 邮箱备注
      address:'',  // 地址
      address_note:'',   // 地址备注
      website:'',  // 网址
      website_note:'', // 网址备注
    },
    


    // 银行信息
    opening_bank:'', // 开户行
    account:'', // 收款账户
    account_name:'', // 开户名称
  })
  const typeList = ref([
    {label:'园区企业',value:1},
    {label:'用户企业',value:2},
  ])
  const customerTypeList = ref([
    {label:'企业',value:1},
  ])
  const statusList= ref([
    {label:'正常',value:1},
    {label:'停用',value:2},
  ])
  const tagList = ref([
    
  ])
  const sumbitType = ref("");
  const addFormRef = ref("");
  const visible_detail = ref(false)
  const setailItem = ref({})
  const detailCentent = ref(0)
  const handleDrtail = (row)=>{
    console.log('查看详情',row)
    let _item = JSON.parse(JSON.stringify(row))
    if(_item.info.length != 0){
      _item.company_data = _item.info[0]
    }else{
      _item.company_data = {
        companyName:'',  // 公司名称
        companyType:'',  // 公司类型
        legalPerson:'',  // 法定代表人
        legalPersonType:'',  //  法人类型
        phoneNumber:'',   // 电话号码
        phoneNumber_note:'',   // 电话备注
        capital:'',       // 注册资本
        realCapital:'',   // 实收注册资金
        companyCode:'',  // 注册码
        creditNo:'',  // 企业信用代码
        orgCode:'',   // 组织机构代码
        businessScope:'',  // 经营范围
        authority:'',  // 登记机关
        companyStatus:'',   // 经营状态
        establishDate:'',  // 成立时间
        operationStartdate:'',  // 营业期限开始时间
        operationEnddate:'',  // 营业期限结束时间
        issueDate:'',  // 核准日期
        province:'',  // 省份
        provinceCode:'',   // 省份行政区号
        city:'',   // 地市
        cityCode:'',  // 地市行政区号
        district:'', // 地区
        districtCode:'',  // 地区行政区号
        companyAddress:'',  // 注册地址
        industry:'',  // 行业
        historyNames:'', // 曾用名
        lastUpdatedTime:'',  // 更新时间
        companyStatus:'',  // 登记状态
        email:'',   // 邮箱
        email_note:'',  // 邮箱备注
        address:'',  // 地址
        address_note:'',   // 地址备注
        website:'',  // 网址
        website_note:'', // 网址备注
      }
    }
    setailItem.value = _item
    detailCentent.value = 0
    visible_detail.value = true
  }
  onMounted(()=>{
    request({
      url:'system/tag/index',
      method: 'get',
      params:{
        openPage:false
      },
    }).then(res=>{
      tagList.value = res.data.items
    })
  })
  const handleSearch = (value) => {
    if (value) {
      loading.value = true;
      request({
        url:'system/dept/info',
        method: 'get',
        params:{
          keyword:value,
          pageNo:1,
          pageSize:1000,
        },
      }).then(res=>{
        console.log('公司信息：',res)
        deptSearchList.value = res.data.items
        loading.value = false;
      })
    } else {
      deptSearchList.value = []
    }
  };
  const handleYinhanInfo = (e)=>{
    console.log(e)
    deptSearchList.value.map((v,i)=>{
      if(v.creditNo == e){
        addItem.value.name = v.companyName
      }
    })
    request({
      url:'system/dept/getCompanyDetail',
      method: 'get',
      params:{
        keyword:e,
        
      },
    }).then(res=>{
      console.log('银行信息：',res)
      let _data = res.data
      addItem.value.company_data.companyType = _data.companyType
      addItem.value.company_data.legalPersonType = _data.legalPersonType
      addItem.value.company_data.phoneNumber = _data.contacts.phoneNumber[0].value || ''
      addItem.value.company_data.phoneNumber_note = _data.contacts.phoneNumber[0].note  || ''
      addItem.value.company_data.capital = _data.capital
      addItem.value.company_data.realCapital = _data.realCapital
      addItem.value.company_data.orgCode = _data.orgCode
      addItem.value.company_data.businessScope = _data.businessScope
      addItem.value.company_data.authority = _data.authority
      addItem.value.company_data.operationStartdate = _data.operationStartdate
      addItem.value.company_data.operationEnddate = _data.operationEnddate
      addItem.value.company_data.issueDate = _data.issueDate
      addItem.value.company_data.province = _data.province
      addItem.value.company_data.provinceCode = _data.provinceCode
      addItem.value.company_data.city = _data.city
      addItem.value.company_data.cityCode = _data.cityCode
      addItem.value.company_data.district = _data.district
      addItem.value.company_data.districtCode = _data.districtCode
      addItem.value.company_data.industry = _data.industry
      addItem.value.company_data.historyNames = _data.historyNames
      addItem.value.company_data.lastUpdatedTime = _data.lastUpdatedTime
      addItem.value.company_data.email = _data.contacts.email[0].value || ''
      addItem.value.company_data.email_note = _data.contacts.email[0].note  || ''
      addItem.value.company_data.address = _data.contacts.address[0].value  || ''
      addItem.value.company_data.address_note = _data.contacts.address[0].note || ''
      addItem.value.company_data.website = _data.contacts.website[0].value || ''
      addItem.value.company_data.website_note = _data.contacts.website[0].note || ''
      console.log(addItem.value)
    })
  }
  const handleKehuInfo = (e)=>{
    
    
  }
  const handleUserList = (row)=>{
    dept_id.value = row.id
    userVisible.value = true
  }
  const handleAddOk = async ()=>{
    if(addItem.value.name == ''){
      Message.error('请输入客户名称')
      return false
    }
    
    if(addItem.value.phone == ''){
      Message.error('请输入客户电话')
      return false
    }
    if(addType.value == 1){
        let res = await dept.save(addItem.value)
        if(res.code == 200){
        	  Message.success('添加成功')
            crudRef.value.requestData()
            return true
        }else{
          return false
        }
    }else{
        let res = await dept.update(addItem.value.id,addItem.value)
        if(res.code == 200){
          Message.success('修改成功')
          crudRef.value.refresh()
          return true
        }else{
          return false
        }
        // dept.update(addItem.value.id,addItem.value).then(res=>{
        //     Message.success('修改成功')
        //     crudRef.value.refresh()
        // })
    }
  }
  const handleAdd = (type,item)=>{
    visible_Add.value = true
    addType.value = type
    if(type == 1){  // 新增
      addItem.value = {
        type:1,
        customer_type:1,
        status:1,
        name:'',
        leader:'',
        phone:'',
        e_mail:'',
        card_id:'',
        file:'',
        tag_ids:[],
        remark:'',
        company_data:{
          companyName:'',  // 公司名称
          companyType:'',  // 公司类型
          legalPerson:'',  // 法定代表人
          legalPersonType:'',  //  法人类型
          phoneNumber:'',   // 电话号码
          phoneNumber_note:'',   // 电话备注
          capital:'',       // 注册资本
          realCapital:'',   // 实收注册资金
          companyCode:'',  // 注册码
          creditNo:'',  // 企业信用代码
          orgCode:'',   // 组织机构代码
          businessScope:'',  // 经营范围
          authority:'',  // 登记机关
          companyStatus:'',   // 经营状态
          establishDate:'',  // 成立时间
          operationStartdate:'',  // 营业期限开始时间
          operationEnddate:'',  // 营业期限结束时间
          issueDate:'',  // 核准日期
          province:'',  // 省份
          provinceCode:'',   // 省份行政区号
          city:'',   // 地市
          cityCode:'',  // 地市行政区号
          district:'', // 地区
          districtCode:'',  // 地区行政区号
          companyAddress:'',  // 注册地址
          industry:'',  // 行业
          historyNames:'', // 曾用名
          lastUpdatedTime:'',  // 更新时间
          companyStatus:'',  // 登记状态
          email:'',   // 邮箱
          email_note:'',  // 邮箱备注
          address:'',  // 地址
          address_note:'',   // 地址备注
          website:'',  // 网址
          website_note:'', // 网址备注
        },
        
        opening_bank:'', // 开户行
        account:'', // 收款账户
        account_name:'', // 开户名称
      }
      customerTypeList.value = [
        {label:'企业',value:1},
      ]
    }else{
        let tag = []
        if(item.tag.length != 0){
            item.tag.map((v,i)=>{
                tag.push(v.tag_id)
            })
        }
        addItem.value = {
            id:item.id,
            type:item.type - 0,
            customer_type:item.customer_type,
            status:item.status,
            name:item.name,
            leader:item.leader,
            phone:item.phone,
            e_mail:item.e_mail,
            card_id:item.card_id,
            file:item.file,
            tag_ids:tag,
            remark:item.remark,
            company_data:{
              companyName:item.info.length != 0?item.info[0].companyName:'',  // 公司名称
              companyType:item.info.length != 0?item.info[0].companyType:'',  // 公司类型
              legalPerson:item.info.length != 0?item.info[0].legalPerson:'',  // 法定代表人
              legalPersonType:item.info.length != 0?item.info[0].legalPersonType:'',  //  法人类型
              phoneNumber:item.info.length != 0?item.info[0].phoneNumber:'',   // 电话号码
              phoneNumber_note:item.info.length != 0?item.info[0].phoneNumber_note:'',   // 电话备注
              capital:item.info.length != 0?item.info[0].capital:'',       // 注册资本
              realCapital:item.info.length != 0?item.info[0].realCapital:'',   // 实收注册资金
              companyCode:item.info.length != 0?item.info[0].companyCode:'',  // 注册码
              creditNo:item.info.length != 0?item.info[0].creditNo:'',  // 企业信用代码
              orgCode:item.info.length != 0?item.info[0].orgCode:'',   // 组织机构代码
              businessScope:item.info.length != 0?item.info[0].businessScope:'',  // 经营范围
              authority:item.info.length != 0?item.info[0].authority:'',  // 登记机关
              companyStatus:item.info.length != 0?item.info[0].companyStatus:'',   // 经营状态
              establishDate:item.info.length != 0?item.info[0].establishDate:'',  // 成立时间
              operationStartdate:item.info.length != 0?item.info[0].operationStartdate:'',  // 营业期限开始时间
              operationEnddate:item.info.length != 0?item.info[0].operationEnddate:'',  // 营业期限结束时间
              issueDate:item.info.length != 0?item.info[0].issueDate:'',  // 核准日期
              province:item.info.length != 0?item.info[0].province:'',  // 省份
              provinceCode:item.info.length != 0?item.info[0].provinceCode:'',   // 省份行政区号
              city:item.info.length != 0?item.info[0].city:'',   // 地市
              cityCode:item.info.length != 0?item.info[0].cityCode:'',  // 地市行政区号
              district:item.info.length != 0?item.info[0].district:'', // 地区
              districtCode:item.info.length != 0?item.info[0].districtCode:'',  // 地区行政区号
              companyAddress:item.info.length != 0?item.info[0].companyAddress:'',  // 注册地址
              industry:item.info.length != 0?item.info[0].industry:'',  // 行业
              historyNames:item.info.length != 0?item.info[0].historyNames:'', // 曾用名
              lastUpdatedTime:item.info.length != 0?item.info[0].lastUpdatedTime:'',  // 更新时间
              companyStatus:item.info.length != 0?item.info[0].companyStatus:'',  // 登记状态
              email:item.info.length != 0?item.info[0].email:'',   // 邮箱
              email_note:item.info.length != 0?item.info[0].email_note:'',  // 邮箱备注
              address:item.info.length != 0?item.info[0].address:'',  // 地址
              address_note:item.info.length != 0?item.info[0].address_note:'',   // 地址备注
              website:item.info.length != 0?item.info[0].website:'',  // 网址
              website_note:item.info.length != 0?item.info[0].website_note:'', // 网址备注
            },
            
            opening_bank:'', // 开户行
            account:'', // 收款账户
            account_name:'', // 开户名称
        }
    }
  }
  const handleType = (e)=>{
    console.log(e)
    if(e == 1){
      customerTypeList.value = [
        {label:'企业',value:1},
      ]
      addItem.customer_type.value = 1
    }else{
      customerTypeList.value = [
        {label:'企业',value:1},
        {label:'个人',value:2},
      ]
      addItem.customer_type.value = 1
    }
  }
  
  const load = () =>{  // 充值结束
    crudRef.value.refresh()
  }
  const handleDetailCancel = ()=>{
    visible_detail.value = false
  }
  const deptMoneyUpdate = async ()=>{   // 修改周期结算
    let res = await FinancialTopDeptMoney.update(haseinfo.value.money.id,{
      settle_day: haseinfo.value.money.settle_day,
      bill_day: haseinfo.value.money.bill_day
    })
    if (res.success) {
      Message.success(res.message)
    }
  }
  const handleTab = async (index) =>{
    if(index != detailCentent.value){
      detailCentent.value = index
      if(index == 1){
        let res = await dept.read({
          id: setailItem.value.id,
        })
        haseinfo.value = res.data
      }
    }
  }
 
  const openShow = async (item,tab) => {
    let obj = {}
    // 1  已支付  2 待支付  3 已退款
    if(tab != ''){
        obj.dept_id = item.id,
        obj.pay_status = tab
    }else{
        obj.dept_id = item.id
    }
    // payOrderRef.value.open(item)
    visible.value = true
    await nextTick()
    payOrderRef.value.crudRef.requestParams = Object.assign(payOrderRef.value.crudRef.requestParams, obj)
    payOrderRef.value.crudRef.refresh()
  }
  
  const options = reactive({
    id: 'flyos_financial_financeLedger',
    rowSelection: {
      showCheckedAll: true
    },
    pk: 'id',
    operationColumn: true,
    operationWidth: 160,
    tablePagination:false,
    pageSize:500,
    formOption: {
      viewType: 'modal',
      width: 600
    },
    api: financialPeriodic.getDeptList,
    // export: {
    //   show: true,
    //   url: 'financial/payOrder/export',
    //   auth: ['financial:payOrder:export']
    // },
    delete: {
      show: true,
      api: dept.deletes,
      auth: ['financial:financeLedger:delete']
    },
    beforeRequest:(params)=>{
        params.orderBy = 'id',
        params.orderType = 'desc'
    },
    afterRequest: (params) => {
      params.map((v, i) => {
        v.money = v.money - 0
        v.wait_pay_money = v.wait_pay_money - 0
        v.pay_money = v.pay_money - 0
        v.retrun_pay_money = v.retrun_pay_money - 0
      })
    },
    
  })
  
  const columns = reactive([
    {
      title: "",
      dataIndex: "id",
      formType: "input",
      addDisplay: false,
      editDisplay: false,
      hide: true,

      commonRules: {
        required: true,
        message: "请输入"
      }
    },
    {
      title: "公司名称",
      dataIndex: "id",
      formType: "select",
      align: "center",
      search: true,
      dict: {
				// 远程通用接口请求，新版代码生成都有一个 remote 接口
				remote: "system/dept/remote",
				// 指定组件接收的props
				props: { label: "name", value: "id" },
				// 开启分页
				openPage: false,
				// 远程请求配置项
				remoteOption: {
					// 按用户名排序
					sort: { id: "desc" }, // 如果不指定排序方式，默认为正序排序
					// 设置查询的字段
					select: ["id", "name"],
					// 设置数据过滤
					filter: {
            status: ['=',1]
					},
					// 关联模型
					relations: [],
				},
        translation: true
			},
    },
    {
      title: "经办人",
      dataIndex: "leader",
      align: "center",
      formType: "input",
      search: true,
      width:120,
    },
    {
      title: "客户类型",
      dataIndex: "customer_type",
      formType: "select",
      align: "center",
      search: true,
      dict:{
        data:[
          {label:'企业',value:1},
          {label:'个人',value:2},
        ],
        translation: true
      }
    },
    {
      title: "标签",
      dataIndex: "tag",
      align: "center",
      formType: "input",
    },
    {
      title: "手机号",
      dataIndex: "phone",
      align: "center",
      formType: "input",
      search: true,
    },
    {
      title: "余额",
      dataIndex: "money",
      sortable: { sortDirections: ['ascend', 'descend'],  },
      align: "center",
      formType: "input",
    },
    // {
    //   title: "到运车数",
    //   align: "center",
    //   width:120,
    //   sortable: {
    //       sortDirections: ['ascend', 'descend'],
    //       sorter: false
    //     },
    //   dataIndex: "daoyun",
    // },
    // {
    //   title: "发运车数",
    //   align: "center",
    //   width:120,
    //   sortable: {
    //       sortDirections: ['ascend', 'descend'],
    //       sorter: false
    //     },
    //   dataIndex: "fayun",
    // },
    // {
    //   title: "总支付金额",
    //   dataIndex: "pay_money",
    //   align: "center",
    //   sortable: {
    //       sortDirections: ['ascend', 'descend']
    //     },
    //   formType: "input",
    // },
    // {
    //   title: "总待支付金额",
    //   align: "center",
    //   sortable: {
    //       sortDirections: ['ascend', 'descend']
    //     },
    //   dataIndex: "wait_pay_money",
    //   formType: "input",
    // },
    // {
    //   title: "总退款金额",
    //   align: "center",
    //   sortable: {
    //       sortDirections: ['ascend', 'descend']
    //     },
    //   dataIndex: "retrun_pay_money",
    //   formType: "input",
    // },
    
    {
      title: "状态",
      dataIndex: "status",
      align: "center",
      formType: "select",
      search: true,
      dict:{
        data:[
          {label:'正常',value:1},
          {label:'停用',value:2},
        ],
        tagColors:{
          1:'green',
          2:'gray'
        },
        translation: true
      }
    },
    {
      title: "创建时间",
      dataIndex: "created_at",
      formType: "range",
      align: "center",
      search: false,
      addDisplay: false,
      editDisplay: false,
      sortable: {
        sortDirections: ["ascend", "descend"],
        sorter: true,
      },
      showTime: true,
    },
  ])

	function update() {
		dept.update(setailItem.value.id, setailItem.value).then((res) => {
			Message.success('保存成功！')
      visible_detail.value = false
      crudRef.value.refresh()
		});
	}
  </script>
  <style lang="less" scoped>
    .font20{
      font-size:20px;
      line-height:28px;
    }
    .font18{
      font-size:18px;
      line-height:26px;
    }
    .font14{
      font-size:14px;
      line-height:22px;
    }
    .font12{
      font-size:12px;
      line-height:20px;
    }
    .bold{
      font-weight:600;
    }
    .hei{
      color:rgba(0,0,0,.9);
    }
    .bule{
      color:rgba(0, 82, 217, 1);
    }
    .green{
      color:rgba(43, 164, 113, 1)
    }
    .hui{
      color:rgba(0,0,0,.4)
    }
    .marr12{
      margin-right:12px;
    }
    .marr2{
      margin-right:2px;
    }
    .marbot16{
      margin-bottom:16px;
    }
    .marbot12{
      margin-bottom:12px;
    }
    .marbot4{
      margin-bottom:4px;
    }
    .marbot24{
      margin-bottom:24px;
    }
    .huiBox{
      padding:12px;
      border-radius:4px;
      background:rgba(246, 246, 246, 1);
    }
    .tabBox{
      border-bottom:1px solid rgba(0,0,0,.15);
      .tab{
        padding:5px 14px 14px;
      }
      .activeTab{
        color:rgba(0, 82, 217, 1);
        border-bottom:3px solid rgba(0, 82, 217, 1);
      }
    }
    .contenBox{
      height:500px;
      padding:12px;
    }
    .contenBox::-webkit-scrollbar{
      display: none;
    }
  </style>

  <script> export default { name: 'financial:financeLedger' } </script>
  